home *** CD-ROM | disk | FTP | other *** search
/ The Charlie Rose Science Series Anthology / The Charlie Rose Science Series Anthology (Pfizer, Inc.)(2008).iso / mac / Charlie Rose Science Series Anthology.app / Contents / Resources / movie.swf / scripts / __Packages / mx / controls / streamingmedia / MiniPlayBar.as < prev    next >
Text File  |  2008-02-01  |  3KB  |  114 lines

  1. class mx.controls.streamingmedia.MiniPlayBar extends MovieClip
  2. {
  3.    function MiniPlayBar()
  4.    {
  5.       super();
  6.       this.init();
  7.    }
  8.    function init()
  9.    {
  10.       this._controller = this._parent;
  11.       this.draw();
  12.    }
  13.    function isVertical()
  14.    {
  15.       return !this._controller.__get__horizontal();
  16.    }
  17.    function getCompletionPercentage()
  18.    {
  19.       var _loc2_ = undefined;
  20.       if(this.isVertical())
  21.       {
  22.          _loc2_ = this.yToPercent(this._thumb._y);
  23.       }
  24.       else
  25.       {
  26.          _loc2_ = this.xToPercent(this._thumb._x);
  27.       }
  28.       return _loc2_;
  29.    }
  30.    function setCompletionPercentage(aPercentage)
  31.    {
  32.       aPercentage = Math.floor(aPercentage);
  33.       if(aPercentage < 1)
  34.       {
  35.          aPercentage = 1;
  36.       }
  37.       else if(aPercentage > 100)
  38.       {
  39.          aPercentage = 100;
  40.       }
  41.       if(this.isVertical())
  42.       {
  43.          var _loc3_ = this.percentToY(aPercentage);
  44.          this._thumb._y = this.getActualHeight() - _loc3_ - 1;
  45.          this._hilite._height = _loc3_ - 1;
  46.          this._hilite._y = this.getActualHeight() - _loc3_ - 2;
  47.       }
  48.       else
  49.       {
  50.          var _loc4_ = this.percentToX(aPercentage);
  51.          this._thumb._x = _loc4_;
  52.          this._hilite._width = _loc4_ - 1;
  53.       }
  54.    }
  55.    function getController()
  56.    {
  57.       return this._controller;
  58.    }
  59.    function draw(h)
  60.    {
  61.       if(this.isVertical())
  62.       {
  63.          this._y = 8;
  64.          if(h == null)
  65.          {
  66.             h = this.getHeight();
  67.          }
  68.          this._tray.setHeight(h);
  69.       }
  70.       else
  71.       {
  72.          var _loc3_ = this.getWidth();
  73.          this._x = 8;
  74.          this._tray.setWidth(this.getWidth());
  75.       }
  76.       this.setCompletionPercentage(this._controller.__get__playPercent());
  77.    }
  78.    function getWidth()
  79.    {
  80.       var _loc2_ = !this.isVertical() ? this._controller.__get__width() - 16 : 6;
  81.       return _loc2_;
  82.    }
  83.    function getHeight()
  84.    {
  85.       var _loc2_ = !this.isVertical() ? 6 : this._controller.__get__height() - 16;
  86.       return _loc2_;
  87.    }
  88.    function getActualHeight()
  89.    {
  90.       var _loc2_ = this._tray.getHeight();
  91.       return _loc2_;
  92.    }
  93.    function xToPercent(x)
  94.    {
  95.       var _loc2_ = 100 * x / (this.getWidth() - 2);
  96.       return _loc2_;
  97.    }
  98.    function percentToX(percent)
  99.    {
  100.       var _loc2_ = (this.getWidth() - 2) * (percent / 100);
  101.       return _loc2_;
  102.    }
  103.    function yToPercent(y)
  104.    {
  105.       var _loc2_ = 100 * (y - 1) / (this.getActualHeight() - 3);
  106.       return _loc2_;
  107.    }
  108.    function percentToY(percent)
  109.    {
  110.       var _loc2_ = (this.getActualHeight() - 3) * (percent / 100) + 1;
  111.       return _loc2_;
  112.    }
  113. }
  114.